package ltd.nullpointer.tcp.core.resolver.parser;

import com.boot2.core.utils.ByteUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author zhangweilin
 * @Description: ascii
 * @date 2019/12/9
 */
@Component
public class AsciiResolverParser implements ResolverParser<String> {

    /**
     * @param byteArr
     * @return
     */
    @Override
    public String resolve(byte[] byteArr,Object obj, Map<String, Object> paramMap) {
        String charsetName = (String) paramMap.get("charsetName");
        String str = ByteUtils.getString(byteArr, charsetName);
        str = str.trim().replaceAll("\0", "");
        return str;
    }
}
